import { AdConfigData } from "../ShiyouAdManager";
import { ui } from "../../../../../ui/layaMaxUI";
import GameAdsManager from "../../GameAdsManager";
import { EventTool } from "../../../Tool/EventTool";


export default class NameImgAdItem extends ui.ShiyouAdView.Items.NameImgAdItemUI {
    private m_appid: string = "";
    private m_applabelName: string = "";
    private m_appskin: string = "";
    private m_adtype: number = -1;
    private m_path:string="";
    private type:string="";
    private order:number=0;

    OnIconBackClick() {
        if (this.m_appid!="") 
        EventTool.UpLoadUserAdData(this.type,this.order,this.m_appid,"2");
        GameAdsManager.Instance.NativeToProgram(this.m_appid,this.m_applabelName,this.m_path,this.type,this.order);
    }


    constructor() {
        super();
        this.m_IconBack.on(Laya.Event.CLICK, this, this.OnIconBackClick);
    }


    SetData(data: AdConfigData,type:string,order:number) {
        this.m_appid = data.AppId;
        this.m_applabelName = data.AppName;
        this.m_path=data.Path;
        this.m_appskin = data.AppIcon;
        this.m_adtype = data.AdType;
        this.type=type;
        this.order=order;
        let showhot = data.ShowHot == 1;
        this.m_HotImg.visible = showhot;
        this.m_GameIcon.skin = this.m_appskin;
        this.m_GameNameLab.text = this.m_applabelName;
        EventTool.UpLoadUserAdData(this.type,this.order,this.m_appid,"1");
    }
}